<?php if (!defined('THINK_PATH')) exit();?><div id="goodsModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"
			aria-hidden="true">×</button>
		<h3 id="myModalLabel"><?php echo ($shopName); ?></h3>
	</div>
	<div class="modal-body" style="padding: 0 15px;margin-top: -1px;">
		<table class="table" style="margin-bottom: 0;">
			<tr>
				<th>1688商品</th>
				<th>阿里同步</th>
				<th style="text-align:center">阿里商品</th>
				<th>平台同步</th>
				<th style="text-align:center">平台商品</th>
			</tr>
			<?php if(is_array($list)): foreach($list as $tao_id=>$item): ?><tr data-id="<?php echo ($tao_id); ?>">
				<td><a href="https://detail.1688.com/offer/<?php echo ($tao_id); ?>.html" target="_blank"><?php echo ($tao_id); ?></a></td>
				<td><?php echo ($item["last_sync"]); ?></td>
				<td style="text-align:center">
					<?php if($item['action'] == 'add'): ?><a class="label label-warning js-add">添加</a>
					<?php elseif($item['action'] == 'hidden'): ?>
						<a class="label label-important js-edit">下架</a>
					<?php elseif($item['action'] == 'sync'): ?>
						<a class="label label-important js-edit">同步</a><?php endif; ?>
				</td>
				<td>
					<?php if($item['is_del'] != '1'): echo ($item["last_update"]); endif; ?>
				</td>
				<td>
					<?php if($item['action'] != 'add'): if ( $item['is_display'] === '' ) { ?>
							<a class="label label-warning" href="<?php echo __MODULE__; ?>/goods/add?tao_id=<?php echo ($tao_id); ?>">添加</a>
						<?php }elseif ( $item['is_display'] == 0 ) { ?>
							<a class="label label-warning" href="<?php echo __MODULE__; ?>/goods/edit?id=<?php echo ($item["id"]); ?>">上架</a>
						<?php }elseif ( $item['is_display'] == 1 ) { ?>
							<a class="label label-important" href="<?php echo __MODULE__; ?>/goods/edit?id=<?php echo ($item["id"]); ?>">同步</a>
						<?php } endif; ?>
				</td>
				<!--td><?php echo ($item['sys_notice']); ?></td-->
			</tr><?php endforeach; endif; ?>
		</table>
	</div>
	<div class="modal-footer">
		<button type="button" class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    	<a type="button" class="btn btn-primary" href="<?php echo __MODULE__; ?>/goods?shop_id=<?php echo ($shop["id"]); ?>">商品管理</a>
	</div>
	
	<script>
	(function(){
		var $modal = $('#goodsModal');
		$modal.modal({backdrop: 'static'}).on('hidden', function(){
			$modal.remove();
			return false;
		});
		
		$modal.on('click', '.js-add', function(){
			var tao_id = $(this).parents('tr:first').data('id');
			$.ajax({
				url: '<?php echo __MODULE__; ?>/alibaba/syncGoods?tao_id=' + tao_id,
				dataType: 'json',
				success: function(goods){
					window.open('<?php echo __MODULE__; ?>/goods/add?tao_id='+tao_id);
				}
			});
			return false;
		}).on('click', '.js-edit', function(){
			var tao_id = $(this).parents('tr:first').data('id');
			$.ajax({
				url: '<?php echo __MODULE__; ?>/alibaba/syncGoods?tao_id=' + tao_id,
				dataType: 'json',
				success: function(goods){
				}
			});
			return false;
		});
	})();
	</script>
</div>